home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / man / timer.man < prev   
Encoding:
Text File  |  1993-09-05  |  3.2 KB  |  100 lines

  1.                         ATARI MACHINE SPECIFIC LIBRARY
  2.  
  3.  
  4.  
  5. NAME
  6.      Timer
  7.  
  8. SYNOPSIS
  9.      #include <Timer.h>
  10.  
  11.      unsigned long Hz200()
  12.      void Delay(unsigned long msec)
  13.  
  14.      class TimerSpeed
  15.  
  16.      void HaltTimerA()
  17.      void SetTimerA(void ISR(), TimerSpeed&)
  18.      void SetTimerA(void ISR(), int Hz)
  19.  
  20. DESCRIPTION
  21.      There are two basic ways in which a real-time application controls
  22.      the speed at which things occurs.  One is by clocking to the vertical
  23.      retrace signal (see DoubleBuffer), the other is to use one of the
  24.      system hardware timers.
  25.  
  26. FUNCTIONS
  27.      unsigned long Hz200()
  28.        Returns the number of 200ths of a seconds since the computer was
  29.        turned on.
  30.  
  31.      void Delay(unsigned long msec)
  32.        Wait for the given number of milliseconds (accurate to 200ths of
  33.        a seconds).
  34.  
  35.      void HaltTimerA()
  36.        Stop Timer A, the only user-free timer.
  37.  
  38.      void SetTimerA(void ISR(), TimerSpeed&);
  39.        Set Timer A to execute the given INTERRUPT Service Routine at
  40.        the speed given.  NOTE:  A regular C function is NOT sufficient
  41.        to use as an ISR (see USAGE below).
  42.  
  43.      void SetTimerA(void ISR(), int Hz)
  44.        A much slower form of the above.
  45.  
  46. CLASSES
  47.      class TimerSpeed is used to overcome the way timer speeds are defined.
  48.      While it is possible to have timers run at almost any frequency, the
  49.      value to give to the hardware for these frequencies are in terms that
  50.      are not usually useful.  By using the TimerSpeed class, these problems
  51.      can be ignored by the programmer.
  52.  
  53. CLASS MEMBERS
  54.   TimerSpeed::
  55.      TimerSpeed(int Hz)
  56.        Create a timer speed as close as possible to the requested speed.
  57.      operator int()
  58.        Returns the actualy speed of the timer, in Hz.
  59.  
  60. USAGE
  61.      When writing an ISR, the programmer is defining a routine that will
  62.      be executed at each pulse of the timer to which it is attached
  63.      (Timer A).  The routine will need to be written using assembler and
  64.      should have the following form:
  65.  
  66.           _ISR:
  67.               bclr   #5,0xFFFFFA0F    | Reset interrupt-pending signal
  68.               moveml ...,sp@-         | Save any used registers
  69.                ...                    | Whatever processing is needed
  70.               moveml sp@+,...         | Restore any used registers
  71.               rte                     | Return from the interrupt
  72.  
  73.      If an interrupt requires to disable itself, use the following in
  74.      the "Whatever processing is needed" code:
  75.  
  76.               bclr   #5,0xFFFFFA07    | Disable interrupt on timer A
  77.               bclr   #5,0xFFFFFA13    | Clear interrupt mask for timer A
  78.  
  79. SEE ALSO
  80.      SampledSound (uses Timer A for playing sounds)
  81.  
  82. BUGS
  83.      The minimal frequency is 82Hz.
  84.      The maximum frequency is limited by the length of the ISR.
  85.  
  86. AUTHOR
  87.      Warwick Allison, 1992.
  88.      warwick@cs.uq.oz.au
  89.  
  90. COPYING
  91.      This functionality is part of the Atari Machine Specific Library,
  92.      and is Copyright 1992 by Warwick W. Allison.
  93.  
  94.      The Atari Machine Specific Library is free and protected under the
  95.      GNU Library General Public License.
  96.  
  97.      You are free to copy and modify these sources, provided you acknowledge
  98.      the origin by retaining this notice, and adhere to the conditions
  99.      described in the GNU LGPL.
  100.